package com.admin.controller;

import java.util.Date;

import com.admin.controller.BaseController.Status;
import com.admin.model.Orders;
import com.admin.model.OrdersReturn;
import com.admin.model.Sys_User;
import com.admin.util.Constants;
import com.admin.util.DateUtil;
import com.admin.util.Page;
import com.admin.util.UtilTools;
import com.alibaba.fastjson.JSONObject;
import com.jfinal.render.JsonRender;

public class OrdersReturnController extends BaseController {
	public static String ORDERSRETURN = "/ordersReturn";
	// 保存
	public void save() {
		try {
			String mobile = this.getPara("mobile");
			String content = this.getPara("content");
			OrdersReturn ordersReturn = getModel(OrdersReturn.class);
			Sys_User user = getSessionAttr(Constants.LOGIN_USER);
			ordersReturn.set("loginname", user.get("loginname"));
			ordersReturn.set("create_date",new Date());
			ordersReturn.set("mobile",mobile);
			ordersReturn.set("content", content);
			ordersReturn.save();
			JSONObject obj = new JSONObject();
			obj.put("loginname", user.get("loginname"));
			obj.put("create_date", DateUtil.format(new Date(),"yyyy-MM-dd hh:mm:ss"));
			obj.put("content", ordersReturn.get("content"));
			render(new JsonRender(obj).forIE());
		} catch (Exception e) {
			e.printStackTrace();
			logger.info(e.getMessage(), e);
			ajax(Status.error,null,null);
		}
	}
}
